package org.wattdepot.simulation.oahugrid.demandcurve;

import java.util.GregorianCalendar;

/** 
 * Implements a simple profile: off peak is 500 MW, shoulder peak 660, priority peak at 1060.
 * @author Philip Johnson
 *
 */
public class StandardDemandCurve extends DailyDemandCurve {
  
  /**
   * Creates a demand curve of [500, 660, 1060].
   * @param date The date for this demand curve.
   */
  public StandardDemandCurve(GregorianCalendar date) {
    super(date);
    // 12:00am - 4:45 am: baseline of 500.
    for (int i = 0; i < 20; i++) {
      demandCurve[i] = 500;
    }
    // 5:00am - 12:45pm: Jump up to 660 in increments of 5 over the next 8 hours.
    for (int i = 20; i < 52; i++) {
      demandCurve[i] = demandCurve[i - 1] + 5;
    }
    // 1:00pm - 5:45pm: stay level at 660.
    for (int i = 52; i < 72; i++) {
      demandCurve[i] = demandCurve[i - 1];
    }
    // 6:00pm - 7:45pm: Jump up to 1060 in increments of 50 over 2 hours.
    for (int i = 72; i < 80; i++) {
      demandCurve[i] = demandCurve[i - 1] + 50;
    }
    // 8:00pm - 11:45pm: drop back to 500, subtract 560 over 2 hours.
    for (int i = 80; i < 88; i++) {
      demandCurve[i] = demandCurve[i - 1] - 70;
    }
    // 8:00pm - 9:45pm: stick at 500.
    for (int i = 88; i < 96; i++) {
      demandCurve[i] = demandCurve[i - 1];
    }
  }

  /**
   * Provides the PeakType for this demand curve.
   * @param period The period
   * @return The PeakType.
   */
  @Override
  public PeakType getPeakType(int period) {
    if ((period > 71) && (period < 85 )) {
      return PeakType.PRIORITYPEAK;
    }
    else if ((period > 19) && (period < 88 )) {
      return PeakType.SHOULDERPEAK;
    }
    // Otherwise we're offpeak.
    return PeakType.OFFPEAK;
  }
}
